package com.siyu.basedata.rsvrgis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.basedata.rsvrgis.domain.RsvrGis;
import com.siyu.basedata.rsvrgis.service.IRsvrGisService;

/**
 * gis数据和水库关联Controller
 *
 * @author hrhy
 * @date 2024-07-18
 */
@RestController
@RequestMapping("/basedata/RsvrGis")
public class RsvrGisController extends BaseController {
    @Autowired
    private IRsvrGisService rsvrGisService;

    /**
     * 查询gis数据和水库关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RsvrGis rsvrGis) {
        startPage();
        List<RsvrGis> list = rsvrGisService.selectRsvrGisList(rsvrGis);
        return getDataTable(list);
    }

    /**
     * 导出gis数据和水库关联列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RsvrGis rsvrGis) {
        List<RsvrGis> list = rsvrGisService.selectRsvrGisList(rsvrGis);
        ExcelUtil<RsvrGis> util = new ExcelUtil<RsvrGis>(RsvrGis.class);
        util.exportExcel(response, list, "gis数据和水库关联数据");
    }

    /**
     * 获取gis数据和水库关联详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(rsvrGisService.selectRsvrGisById(id));
    }

    /**
     * 新增gis数据和水库关联
     */
    @PostMapping
    public AjaxResult add(@RequestBody RsvrGis rsvrGis) {
        return toAjax(rsvrGisService.insertRsvrGis(rsvrGis));
    }

    /**
     * 修改gis数据和水库关联
     */
    @PutMapping
    public AjaxResult edit(@RequestBody RsvrGis rsvrGis) {
        return toAjax(rsvrGisService.updateRsvrGis(rsvrGis));
    }

    /**
     * 删除gis数据和水库关联
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(rsvrGisService.deleteRsvrGisByIds(ids));
    }
}
